/* ========== 现代设计工具布局（浅色主题）========== */
.geometry-workspace {
  height: 100vh;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
}

/* ========== 顶部工具栏 ========== */
.workspace-header {
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.workspace-header h1 {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #1d1d1f;
  margin: 0;
}

.header-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  margin-left: 1rem;
}

.form-field-inline {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.form-field-inline label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #86868b;
  white-space: nowrap;
}

.form-field-inline input,
.form-field-inline select {
  padding: 0.375rem 0.625rem;
  border: 1px solid #d2d2d7;
  border-radius: 4px;
  font-size: 0.75rem;
  min-width: 120px;
  background: #ffffff;
  color: #1d1d1f;
}

.form-field-inline input:focus,
.form-field-inline select:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.back-btn {
  background: #3658f0;
  border: none;
  color: #ffffff;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s;
  padding: 0.375rem 0.75rem;
  margin-right: 1rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.back-btn:hover {
  background: #3658f0;
}


.settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-btn:hover {
  background: #5a6268;
}

.save-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 1rem;
  background: #007aff;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.save-btn:hover:not(:disabled) {
  background: #0051d5;
}

.save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== 主内容区 ========== */
.workspace-content {
  flex: 1;
  display: flex;
  height: calc(100vh - 48px);
  overflow: hidden;
  background: #f5f5f5;
}

.workspace-content.no-states .states-panel {
  display: none;
}

/* ========== 特殊模型提示 ========== */
.special-model-notice {
  margin: 1rem;
  background: rgba(255, 149, 0, 0.08);
  border: 1px solid rgba(255, 149, 0, 0.3);
  border-radius: 6px;
  padding: 1rem;
  display: flex;
  gap: 1rem;
}

.notice-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ff9500;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notice-content strong {
  display: block;
  font-size: 0.875rem;
  color: #1d1d1f;
  margin-bottom: 0.25rem;
}

.notice-content p {
  color: #86868b;
  margin: 0;
  line-height: 1.4;
  font-size: 0.75rem;
}

/* ========== 左侧工具面板（窄边栏）========== */
.toolbar {
  width: 56px;
  min-width: 56px;
  background: #ffffff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.toolbar h3 {
  display: none;
}

.tool-group {
  width: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.tool-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  color: #86868b;
  position: relative;
}

.tool-btn span {
  display: none;
}

.tool-btn:hover {
  background: #f5f5f7;
  color: #1d1d1f;
}

.tool-btn.active {
  background: #007aff;
  color: white;
}

.tool-icon {
  width: 20px;
  height: 20px;
}

/* 工具提示 */
.tool-btn::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  margin-left: 0.5rem;
  background: #1d1d1f;
  color: #ffffff;
  padding: 0.375rem 0.625rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tool-btn:hover::after {
  opacity: 1;
}

.action-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #86868b;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.action-btn span {
  display: none;
}

.action-btn:hover:not(:disabled) {
  background: #f5f5f7;
  color: #1d1d1f;
}

.action-btn.active {
  background: #007aff;
  color: white;
}

.action-btn.add-constant-btn {
  background: transparent;
  color: var(--text-secondary);
}

.action-btn.add-constant-btn:hover:not(:disabled) {
  background: var(--background-tertiary);
  color: var(--text-primary);
}

.action-btn.add-expression-btn {
  background: transparent;
  color: var(--text-secondary);
}

.action-btn.add-expression-btn:hover:not(:disabled) {
  background: var(--background-tertiary);
  color: var(--text-primary);
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.action-btn.danger:hover:not(:disabled) {
  background: #ff3b30;
  color: white;
}

/* 工具提示 */
.action-btn::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  margin-left: 0.5rem;
  background: #1d1d1f;
  color: #ffffff;
  padding: 0.375rem 0.625rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.action-btn:hover::after {
  opacity: 1;
}

/* 常量列表 */
.constants-list {
  display: none;
}

.constant-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem;
  background: #ffffff;
  border-radius: 4px;
  margin-bottom: 0.25rem;
  border: 1px solid #e0e0e0;
}

.constant-info {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex: 1;
}

.constant-name {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #1d1d1f;
}

.constant-value {
  color: #007aff;
  font-weight: 600;
  font-size: 0.75rem;
}

.delete-constant-btn {
  background: none;
  border: none;
  color: #ff3b30;
  cursor: pointer;
  padding: 0.125rem;
  display: flex;
  align-items: center;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.delete-constant-btn:hover {
  opacity: 1;
}

.empty-hint {
  text-align: center;
  color: #86868b;
  font-size: 0.6875rem;
  padding: 0.75rem;
  margin: 0;
}

/* 常量模式面板 */
.constant-mode-panel {
  position: fixed;
  bottom: 1rem;
  left: 72px;
  width: 280px;
  padding: 0.875rem;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.constant-mode-info strong {
  display: block;
  color: #007aff;
  font-size: 0.75rem;
  margin-bottom: 0.375rem;
}

.constant-mode-info .hint-text {
  font-size: 0.6875rem;
  color: #86868b;
  margin: 0.25rem 0;
}

.constant-mode-info .selected-points {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #007aff;
  font-weight: 500;
  font-family: 'SF Mono', Monaco, monospace;
}

.constant-mode-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.constant-mode-actions .action-btn {
  flex: 1;
  width: auto;
  height: 32px;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  background: #f5f5f7;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

.constant-mode-actions .action-btn span {
  display: inline;
}

.constant-mode-actions .action-btn:hover {
  background: #e8e8ed;
}

.constant-mode-actions .action-btn.danger {
  background: #ff3b30;
  color: white;
}

.constant-mode-actions .action-btn.danger:hover {
  background: #e6281d;
}

/* 常量配置面板 */
.constant-config-panel {
  position: fixed;
  bottom: 1rem;
  left: 72px;
  width: auto;
  max-width: 500px;
  padding: 0.875rem;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.constant-config-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.constant-config-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.constant-config-row label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #1d1d1f;
  min-width: 60px;
}

.constant-type-buttons {
  display: flex;
  gap: 0.375rem;
}

.type-btn {
  padding: 0.375rem 0.75rem;
  background: #f5f5f7;
  border: 1px solid #d2d2d7;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #1d1d1f;
  cursor: pointer;
  transition: all 0.15s;
}

.type-btn:hover {
  background: #e8e8ed;
}

.type-btn.active {
  background: #007aff;
  border-color: #007aff;
  color: white;
}

.constant-name-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: #f5f5f7;
  border: 1px solid #d2d2d7;
  border-radius: 4px;
  font-size: 0.875rem;
  color: #1d1d1f;
  outline: none;
  transition: all 0.15s;
}

.constant-name-input:focus {
  background: white;
  border-color: #007aff;
}

.constant-name-input::placeholder {
  color: #86868b;
}

.constant-config-actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e0e0e0;
}

.constant-config-actions .action-btn {
  flex: 1;
  height: 32px;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  background: #f5f5f7;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

.constant-config-actions .action-btn:hover {
  background: #e8e8ed;
}

.constant-config-actions .action-btn.danger {
  background: #ff3b30;
  color: white;
}

.constant-config-actions .action-btn.danger:hover {
  background: #ff2d22;
}

/* 表达式编辑模式面板 */
.expression-mode-panel {
  position: fixed;
  bottom: 1rem;
  left: 72px;
  width: auto;
  max-width: 700px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 100;
  overflow: hidden;
}

.expression-mode-header {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.expression-mode-content {
  padding: 1rem;
}

.expression-mode-preview {
  min-height: 2.5rem;
  padding: 0.75rem;
  background: #f5f5f7;
  border: 2px solid #d2d2d7;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1.5;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}

.expression-mode-preview:focus-within {
  border-color: #007aff;
}

.expression-mode-preview .part-constant {
  font-weight: 600;
  color: #007aff;
  font-size: 1.05rem;
}

.expression-mode-preview .part-constant sub {
  font-size: 0.6em;
  vertical-align: baseline;
  position: relative;
  bottom: -0.25em;
}

.expression-mode-preview .part-number {
  font-weight: 500;
  color: #34c759;
}

.expression-mode-preview .part-operator {
  color: #86868b;
  margin: 0 0.2rem;
  font-weight: 500;
}

.expression-mode-preview .placeholder-text {
  color: #86868b;
  font-size: 0.8125rem;
  font-style: italic;
}

.expression-mode-selectors {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.expression-selector-group {
  background: #f9f9fb;
  border: 1px solid #e5e5ea;
  border-radius: 6px;
  padding: 0.75rem;
}

.expression-selector-group label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 0.5rem;
}

.expression-selector-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.constant-selector,
.operator-selector,
.number-input-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.selector-btn {
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border: 1.5px solid #d2d2d7;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1d1d1f;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.constant-selector .selector-btn {
  color: #007aff;
  border-color: #007aff;
  background: rgba(0, 122, 255, 0.05);
}

.constant-selector .selector-btn:hover {
  background: rgba(0, 122, 255, 0.15);
  border-color: #0051d5;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 122, 255, 0.2);
}

.operator-selector .selector-btn {
  min-width: 36px;
  padding: 0.5rem;
  text-align: center;
}

.selector-btn:hover {
  background: #e8e8ed;
  border-color: #007aff;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.selector-btn:active {
  transform: translateY(0) scale(0.97);
}

.selector-btn.undo {
  color: #ff3b30;
  border-color: #ff3b30;
  background: rgba(255, 59, 48, 0.05);
  font-size: 1.125rem;
  padding: 0.5rem 0.625rem;
}

.selector-btn.undo:hover {
  background: rgba(255, 59, 48, 0.15);
  border-color: #ff2d22;
}

.number-input-selector {
  width: 100%;
}

.number-input-selector input {
  flex: 1;
  min-width: 120px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1.5px solid #d2d2d7;
  border-radius: 6px;
  background: #ffffff;
  transition: all 0.2s;
}

.number-input-selector input:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.number-input-selector .selector-btn {
  background: #34c759;
  color: white;
  border-color: #34c759;
}

.number-input-selector .selector-btn:hover {
  background: #2fb350;
  border-color: #2fb350;
}

.expression-mode-actions {
  display: flex;
  gap: 0.625rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e5ea;
}

.expression-mode-actions .action-btn {
  flex: 1;
  height: 38px;
  padding: 0 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  background: #f5f5f7;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.expression-mode-actions .action-btn:hover {
  background: #e8e8ed;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.expression-mode-actions .action-btn.danger {
  background: #ff3b30;
  color: white;
}

.expression-mode-actions .action-btn.danger:hover {
  background: #ff2d22;
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.3);
}

/* ========== 中间画布区 ========== */
.canvas-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
  position: relative;
  overflow: hidden;
}

/* 监控面板容器 */
.monitors-container {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 10;
}

/* 常量监控面板 */
.constants-monitor {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  width: 320px;
}

.constants-monitor-header {
  padding: 0.5rem 0.75rem;
  background: #f5f5f7;
  border-bottom: 1px solid #e0e0e0;
  border-radius: 6px 6px 0 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #1d1d1f;
}

.constants-monitor-list {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  max-height: 400px;
  overflow-y: auto;
}

.constant-monitor-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  background: #f5f5f7;
  border-radius: 4px;
  transition: all 0.15s;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
}

.constant-monitor-item:active {
  cursor: grabbing;
}

.constant-monitor-item:hover {
  background: #e8e8ed;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.constant-monitor-item.dragging {
  opacity: 0.5;
}

.constant-monitor-item.drag-over {
  border-top: 2px solid #007aff;
}

.constant-monitor-name {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #1d1d1f;
  flex-shrink: 0;
}

.constant-monitor-name sub {
  font-size: 0.5em;
  vertical-align: baseline;
  position: relative;
  bottom: -0.2em;
}

.constant-monitor-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: #007aff;
  font-family: 'SF Mono', Monaco, monospace;
  white-space: nowrap;
}

.constant-monitor-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
  align-items: center;
}

.constant-monitor-edit,
.constant-monitor-copy,
.constant-monitor-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}

.constant-monitor-edit {
  color: #34c759;
}

.constant-monitor-copy {
  color: #007aff;
}

.constant-monitor-delete {
  color: #ff3b30;
}

/* 可选择的常量项 */
.constant-monitor-item.selectable {
  transition: background-color 0.2s, border-color 0.2s;
}

.constant-monitor-item.selectable:hover {
  background-color: #f5f5f7;
  border-left: 3px solid #007aff;
  padding-left: 9px;
}

.constant-monitor-item.selected {
  background-color: #e3f2fd;
  border-left: 3px solid #007aff;
  padding-left: 9px;
}

.constant-monitor-item:hover .constant-monitor-edit,
.constant-monitor-item:hover .constant-monitor-copy,
.constant-monitor-item:hover .constant-monitor-delete {
  opacity: 0.6;
}

.constant-monitor-edit:hover {
  opacity: 1 !important;
  background: rgba(52, 199, 89, 0.1);
}

.constant-monitor-copy:hover {
  opacity: 1 !important;
  background: rgba(0, 122, 255, 0.1);
}

.constant-monitor-delete:hover {
  opacity: 1 !important;
  background: rgba(255, 59, 48, 0.1);
}

.constants-monitor-list::-webkit-scrollbar {
  width: 4px;
}

.constants-monitor-list::-webkit-scrollbar-thumb {
  background: #d2d2d7;
  border-radius: 2px;
}

.constants-monitor-list::-webkit-scrollbar-thumb:hover {
  background: #aeaeb2;
}

/* 表达式监控面板 */
.expressions-monitor {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  width: 320px;
}

.expressions-monitor-header {
  padding: 0.5rem 0.75rem;
  background: #f5f5f7;
  border-bottom: 1px solid #e0e0e0;
  border-radius: 6px 6px 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1d1d1f;
}

.expressions-monitor-list {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  max-height: 400px;
  overflow-y: auto;
}

.expression-monitor-item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.5rem;
  background: #f5f5f7;
  border-radius: 6px;
  transition: all 0.15s;
}

.expression-monitor-item:hover {
  background: #e8e8ed;
}

.expression-monitor-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.expression-monitor-formula {
  font-size: 0.875rem;
  font-weight: 500;
  color: #1d1d1f;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

/* 分式样式 */
.fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 0.125rem;
}

.fraction-numerator,
.fraction-denominator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.125rem;
  font-size: 0.75rem;
}

.fraction-line {
  width: 100%;
  height: 1px;
  background: #1d1d1f;
  margin: 1px 0;
  min-width: 20px;
}

.expression-monitor-formula sub {
  font-size: 0.5em;
  vertical-align: baseline;
  position: relative;
  bottom: -0.2em;
}

.expression-monitor-formula .operator-divide,
.expression-monitor-formula .operator-multiply,
.expression-monitor-formula .operator-equal {
  color: #86868b;
  margin: 0 0.125rem;
}

.expression-monitor-result {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #34c759;
  font-family: 'SF Mono', Monaco, monospace;
}

.expression-monitor-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.25rem;
  justify-content: flex-end;
}

.expression-monitor-edit,
.expression-monitor-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}

.expression-monitor-edit {
  color: #007aff;
}

.expression-monitor-delete {
  color: #ff3b30;
}

.expression-monitor-item:hover .expression-monitor-edit,
.expression-monitor-item:hover .expression-monitor-delete {
  opacity: 0.6;
}

.expression-monitor-edit:hover {
  opacity: 1 !important;
  background: rgba(0, 122, 255, 0.1);
}

.expression-monitor-delete:hover {
  opacity: 1 !important;
  background: rgba(255, 59, 48, 0.1);
}

.canvas-toolbar {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.canvas-toolbar .hint {
  color: #1d1d1f;
  font-size: 0.6875rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.canvas-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f5f5f5;
  padding: 2rem;
  overflow: hidden;
}

.canvas-wrapper canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
  background: #ffffff;
  border-radius: 2px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* ========== 右侧属性面板 ========== */
.properties-panel {
  width: 420px;
  background: #ffffff;
  border-left: 1px solid #e0e0e0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
}

.properties-panel h3 {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem 0;
}

.properties-panel h3:not(:first-child) {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e0e0e0;
}

.selected-info {
  background: #f5f5f7;
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.selected-info p {
  margin: 0.5rem 0;
  color: #86868b;
  font-size: 0.6875rem;
  display: flex;
  justify-content: space-between;
}

.selected-info p:first-child {
  margin-top: 0;
}

.selected-info p:last-child {
  margin-bottom: 0;
}

.selected-info p strong {
  color: #1d1d1f;
  font-weight: 500;
}

.form-group {
  margin-bottom: 1rem;
  max-width: 100%;
  box-sizing: border-box;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-weight: 500;
  color: #1d1d1f;
  margin-bottom: 0.375rem;
  font-size: 0.6875rem;
}

.form-group input[type="text"],
.form-group input[type="number"] {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem;
  border: 1px solid #d2d2d7;
  border-radius: 4px;
  font-size: 0.75rem;
  background: #ffffff;
  color: #1d1d1f;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-weight: 400;
  font-size: 0.75rem;
  color: #1d1d1f;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #007aff;
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  color: #86868b;
  line-height: 1.3;
}

/* ========== 状态管理面板 ========== */
.states-panel {
  width: 350px;
  background: #ffffff;
  border-left: 1px solid #e0e0e0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.states-header {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid #e0e0e0;
}

.states-header h3 {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.5rem 0;
}

.add-state-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  background: #1890ff;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.add-state-btn:hover {
  background: #40a9ff;
}

.states-list {
  padding: 0.5rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.state-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  min-height: 38px; /* 确保所有按钮高度一致 */
}

.state-item:hover {
  background: #f5f5f7;
  border-color: #e0e0e0;
}

.state-item.active {
  background: #1890ff;
  color: white;
  border-color: #1890ff;
}

/* 拖拽状态样式 */
.state-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.state-item[draggable="true"] {
  cursor: grab;
}

.state-item[draggable="true"]:active {
  cursor: grabbing;
}

.state-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  min-width: 0;
}

.state-info svg {
  flex-shrink: 0;
}

.state-label {
  font-weight: 500;
  font-size: 0.8125rem;
  color: #1d1d1f;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-item.active .state-label {
  color: white;
}

.state-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  /* 始终占据空间，确保按钮高度一致 */
  min-width: 48px; /* 两个按钮的宽度 (22px * 2 + 0.25rem gap) */
}

.state-item:hover .state-actions,
.state-item.active .state-actions {
  opacity: 1;
}

.edit-state-btn,
.delete-state-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  color: #86868b;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.edit-state-btn svg,
.delete-state-btn svg {
  width: 14px;
  height: 14px;
}

.state-item.active .edit-state-btn,
.state-item.active .delete-state-btn {
  color: white;
}

.edit-state-btn:hover {
  background: rgba(24, 144, 255, 0.1);
  color: #1890ff;
}

.state-item.active .edit-state-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.delete-state-btn:hover {
  background: rgba(255, 59, 48, 0.1);
  color: #ff3b30;
}

.state-item.active .delete-state-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.current-state-info {
  padding: 0.5rem 0.625rem;
  margin: 0.5rem 0.625rem;
  background: #f5f5f7;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}

.current-state-info p {
  margin: 0;
  font-size: 0.75rem;
  color: #86868b;
  line-height: 1.4;
}

.current-state-info strong {
  color: #1890ff;
  font-weight: 600;
}

.save-state-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.5rem;
  background: #34c759;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.save-state-btn:hover {
  background: #30b350;
}

.states-help {
  padding: 0.75rem;
  margin: 0.5rem;
  background: #f5f5f7;
  border-radius: 4px;
}

.states-help .help-text {
  margin: 0 0 0.375rem 0;
  font-weight: 500;
  color: #1d1d1f;
  font-size: 0.6875rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.states-help ul {
  margin: 0;
  padding-left: 1rem;
}

.states-help li {
  margin: 0.25rem 0;
  font-size: 0.6875rem;
  color: #86868b;
  line-height: 1.3;
}

.drag-handle {
  cursor: grab;
  color: #86868b;
}

.drag-handle:active {
  cursor: grabbing;
}

/* ========== 滚动条样式 ========== */
.toolbar::-webkit-scrollbar,
.properties-panel::-webkit-scrollbar,
.states-panel::-webkit-scrollbar {
  width: 6px;
}

.toolbar::-webkit-scrollbar-track,
.properties-panel::-webkit-scrollbar-track,
.states-panel::-webkit-scrollbar-track {
  background: transparent;
}

.toolbar::-webkit-scrollbar-thumb,
.properties-panel::-webkit-scrollbar-thumb,
.states-panel::-webkit-scrollbar-thumb {
  background: #d2d2d7;
  border-radius: 3px;
}

.toolbar::-webkit-scrollbar-thumb:hover,
.properties-panel::-webkit-scrollbar-thumb:hover,
.states-panel::-webkit-scrollbar-thumb:hover {
  background: #aeaeb2;
}

/* ========== 响应式布局 ========== */
@media (max-width: 1400px) {
  .workspace-content {
    flex-direction: column;
    height: auto;
  }

  .toolbar {
    width: 100%;
    height: 56px;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
    padding: 0 0.75rem;
  }

  .tool-group {
    flex-direction: row;
  }

  .properties-panel,
  .states-panel {
    width: 100%;
    border-left: none;
    border-bottom: 1px solid #e0e0e0;
    max-height: 300px;
  }

  .canvas-section {
    min-height: 500px;
  }
}

@media (max-width: 768px) {
  .workspace-header {
    padding: 0.5rem;
    flex-wrap: wrap;
    height: auto;
  }

  .workspace-header h1 {
    font-size: 0.75rem;
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .header-form {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    margin-left: 0;
  }

  .form-field-inline {
    width: 100%;
  }

  .form-field-inline input,
  .form-field-inline select {
    min-width: 100%;
  }
}

/* ========== 约束信息面板 ========== */
.constraints-panel {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 240px;
  max-width: 340px;
  z-index: 15;
  animation: slideInRight 0.2s ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.constraints-panel-header {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px 8px 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.constraints-panel-content {
  padding: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.constraint-group {
  margin-bottom: 0.75rem;
}

.constraint-group:last-child {
  margin-bottom: 0;
}

.constraint-group-title {
  font-size: 0.625rem;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.375rem 0.5rem;
  margin-bottom: 0.25rem;
}

.constraint-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  margin-bottom: 0.375rem;
  transition: all 0.2s ease;
}

.constraint-item:hover {
  background: #e9ecef;
  border-color: #dee2e6;
  transform: translateX(-2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.constraint-item:last-child {
  margin-bottom: 0;
}

.constraint-desc {
  font-size: 0.6875rem;
  color: #495057;
  flex: 1;
  margin-right: 0.5rem;
}

.constraint-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: #dc3545;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.constraint-delete-btn:hover {
  background: #dc3545;
  color: #ffffff;
  transform: scale(1.1);
}

.constraint-delete-btn:active {
  transform: scale(0.95);
}
